class Solution:
    def toGoatLatin(self, sentence: str) -> str:
        vowels = set('aeiouAEIOU')  
        words = sentence.split()  
        result = []
        for i,word in enumerate(words):
            if word[0] in vowels:
                transformed_word = word+"ma"
            else:
                transformed_word = word[1:]+word[0]+"ma"
            a_suffix = 'a'*(i+1)
            result.append(transformed_word+a_suffix)
        return ' '.join(result)
